package com.cty.service.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.cty.dubbo.service.MenuDubboService;
import com.cty.pojo.Menu;
import com.cty.service.MenuService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Auther: cty
 * @Date: 2020/3/29 20:19
 * @Description:
 * @version: 1.0
 */
@Service
public class MenuServiceImpl implements MenuService {
    Logger log = Logger.getLogger(MenuServiceImpl.class);

    @Reference
    private MenuDubboService menuDubboService;

    @Override
    public List<Menu> showAllMenu() {
        log.info("发起查询所有菜单信息请求");
        return this.menuDubboService.selAllDubboService();
    }

    @Override
    public Map<String, Object> showOneMenu(int id) {
        Map<String, Object> map = new HashMap<>();
        map.put("menu", this.menuDubboService.selOneDubboService(id));
        map.put("allMenu", this.menuDubboService.selAllDubboService());
        log.info("进入修改页面");
        return map;
    }

    @Override
    public int updateMenu(Menu menu) {
        log.info("发起修改菜单信息请求");
        return this.menuDubboService.updOneDubboService(menu);
    }
}
